/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package jmmos.gameserver.model.actor.instance;

import jmmos.gameserver.ai.CtrlEvent;
import jmmos.gameserver.model.actor.MMOCharacter;
import jmmos.gameserver.model.actor.templates.MMONpcTemplate;
import jmmos.gameserver.network.NpcStringId;
import jmmos.gameserver.network.clientpackets.Say2;
import jmmos.gameserver.network.serverpackets.CreatureSay;
import jmmos.util.Rnd;

public class MMOPenaltyMonsterInstance extends MMOMonsterInstance
{
	private MMOPcInstance _ptk;
	
	public MMOPenaltyMonsterInstance(int objectId, MMONpcTemplate template)
	{
		super(objectId, template);
		setInstanceType(InstanceType.MMOPenaltyMonsterInstance);
	}
	
	@Override
	public MMOCharacter getMostHated()
	{
		if (_ptk != null)
		{
			return _ptk; // always attack only one person
		}
		return super.getMostHated();
	}
	
	public void setPlayerToKill(MMOPcInstance ptk)
	{
		if (Rnd.get(100) <= 80)
		{
			CreatureSay cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), NpcStringId.YOUR_BAIT_WAS_TOO_DELICIOUS_NOW_I_WILL_KILL_YOU);
			this.broadcastPacket(cs);
		}
		_ptk = ptk;
		addDamageHate(ptk, 0, 10);
		getAI().notifyEvent(CtrlEvent.EVT_ATTACKED, ptk);
		addAttackerToAttackByList(ptk);
	}
	
	@Override
	public boolean doDie(MMOCharacter killer)
	{
		if (!super.doDie(killer))
		{
			return false;
		}
		
		if (Rnd.get(100) <= 75)
		{
			CreatureSay cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), NpcStringId.I_WILL_TELL_FISH_NOT_TO_TAKE_YOUR_BAIT);
			this.broadcastPacket(cs);
		}
		return true;
	}
}
